storethis.getEditor().load();
var items = new Array();
for(var i = 0; i < store.getCount(); i++) {
	var menu = store.getAt(i);
	if(menu.get('children') != undefined) {
		if(menu.get('children') != "") {
			for(var j = 0; j < menu.get('children').length; j++) {
				subItems = subItems + addMenu(menu.get('children')[j]) + ",";
			}
			subItems = subItems.substring(0, subItems.length - 1);
			console.log(subItems);
		 	menuId = menu.get('menuId');
		 	title = menu.get('text');
			var em = Ext.extend(Ext.app.Module, {
				id: menuId,
				init: function() {
	    			var temp = "this.launcher = { " +
            				"text: '" + title + "', " +
            				"iconCls: 'settings', " +
            				"handler: function() { " +
							"	return false;" +
							"}," +
            				"scope: this, " +
							"menu: {items:[" + subItems + "]}," +			
     	 					"windowId: " + menuId + "}";
       					eval(temp);
					},
 					createWindow: function(src) {
						var desktop = this.app.getDesktop();
						var win = desktop.getWindow(src.id); 
						if(!win) {
							win = desktop.createWindow({
								id: src.windowId,
								title: src.text,
								width: 740,
								height: 480,
								shim: false,
								//closeAction: 'hide',
							animCollapse: false,
							border: false,
							constrainHeader: true,
							items: new Ext.Panel({
								title: src.text,
								header: false,
								html: '<iframe scrolling="auto" frameborder="0" width="100%" height="100%" src=' + src.url + '></iframe>',
								border: false
							})
						})
					}
					win.show();
				}
			});
			items.push(new em());
			subItems = '';
		} else {
			menuId = menu.get('menuId');
			title = menu.get('text');
			url = menu.get('url');
			var RootModule = Ext.extend(Ext.app.Module, {
					id:menuId,
					init: function() {
						this.launcher = {
							text: title,
							iconCls: 'settings', 
							handler: this.createWindow,
							scope: this,
							url: url,		
							windowId: menuId
						}
					},
					createWindow:function() { 
			        	var desktop = this.app.getDesktop();
			        	var win = desktop.getWindow(menuId); 
			        	if(!win) {
			        		win = desktop.createWindow({
								id: menuId,
								title: title,
								width: 740,
								height: 480,
								shim: false,
								animCollapse: false,
								border: false,
								constrainHeader: true,
								items: new Ext.Panel({
									title: title,
									header: false,
									html: '<iframe scrolling="auto" frameborder="0" width="100%" height="100%" src=' + url + '></iframe>',
									border: false
								})
			    			})
			    		}
 						win.show();
					}
			});
			items.push(new RootModule());
		}
	}
}
return items;
